home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n03 / oopasm.exe / EXEC.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-04-16  |  1.8 KB  |  96 lines

  1.     .MODEL    SMALL
  2.  
  3.     INCLUDE    equates.inc
  4.     INCLUDE    instance.inc
  5.     INCLUDE    messages.inc
  6.     INCLUDE    objects.inc
  7.  
  8. IF1
  9.     INCLUDE    macros.mac
  10.     INCLUDE    objects.mac
  11. ENDIF
  12.  
  13.     EXTRN    getDrive:NEAR
  14.  
  15.     EXTRN    FileName:WORD
  16.     EXTRN    Self:WORD
  17.     EXTRN    Video:WORD
  18.  
  19.     .CODE
  20.  
  21. StackSeg    DW    0
  22. StackPtr    DW    0
  23.  
  24.  
  25.  
  26. COMMENT    %
  27. ==============================================================================
  28. Gets the default child process name (usually C:\COMMAND.COM).
  29.  
  30. =============================================================================%
  31. getDefaultPgm    PROC    NEAR
  32.     call        getDrive        ;Get current drive
  33.     lea        si,PgmName        ;Get addr of program name
  34. gdp1:    lodsb                    ;Get a byte
  35.     mov        Bptr[di],al        ;Move byte into buffer
  36.     inc        di            ;Point to next byte
  37.     notZero        al,gdp1            ;Loop until zero encountered
  38.     mov        ParCmd,OFFSET PgmArgs    ;Set command tail
  39.     ret
  40. getDefaultPgm    ENDP
  41.  
  42.  
  43.  
  44. IF Dbug
  45.     PUBLIC    exeChild
  46. ENDIF
  47. COMMENT    %
  48. ==============================================================================
  49. Loads and executes a child process.
  50.  
  51. =============================================================================%
  52. exeChild    PROC    NEAR
  53.     pushData    <ds,es>
  54.     push        ds
  55.     pop        es
  56.     mov        cs:StackSeg,ss        ;Save stack
  57.     mov        cs:StackPtr,sp
  58.     lea        dx,FileName        ;Get addr of program name
  59.     lea        bx,ParBlk
  60.     mov        al,0            ;Load/Run program
  61.     mov        ah,4Bh            ;Pass service number
  62.     int        DosInt            ;DOS interrupt
  63.     mov        ss,cs:StackSeg        ;Restore stack
  64.     mov        sp,cs:StackPtr
  65.     popData        <es,ds>
  66.     ret
  67. exeChild    ENDP
  68.  
  69.  
  70.  
  71.     .DATA
  72.  
  73.     PUBLIC    ParCmd
  74. PgmName        DB    "COMMAND.COM",0
  75. PgmArgs        DB    0,CR
  76. ParBlk        EQU    $
  77.         DW    0
  78. ParCmd        DW    OFFSET PgmArgs
  79.         DW    SEG PgmArgs
  80.         DD    -1
  81.         DD    -1
  82.  
  83.  
  84. defMsg    Exec,\
  85.     Execute,\
  86.     <getDefaultPgm,,exeChild>
  87.  
  88. defObj    Exec,\
  89.     <>,\
  90.     <>,\
  91.     <Execute>
  92.  
  93.  
  94.  
  95.     END
  96.